#pragma once
#include <SFML/Graphics.hpp>

class Bullet {
public:
    Bullet(const sf::Vector2f& position, float rotation);
    
    void update(sf::Time deltaTime);
    void render(sf::RenderWindow& window);
    
    bool isOutOfBounds() const;
    sf::FloatRect getBounds() const;
    
    static void loadTexture();

private:
    static sf::Texture bulletTexture;
    static bool textureLoaded;
    
    sf::Sprite mSprite;
    sf::Vector2f mVelocity;
    sf::Clock mLifetimeClock;  // 子弹生命周期计时器
    
    static constexpr float SPEED = 400.f;  // 子弹速度
    static constexpr float SIZE = 8.f;     // 子弹大小
    
public:
    sf::Time getLifetime() const { return mLifetimeClock.getElapsedTime(); }
};